package xanatorium.Zeiterfassung.data.db;

import xanatorium.Zeiterfassung.data.EntryDAO;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

public class WorkTimeDictionaryHelper extends SQLiteOpenHelper {

	private static final String DATABASE_NAME = "zeiterfassung.db";
	private static final int DATABASE_VERSION = 2;
	private static final String DICTIONARY_TABLE_CREATE = "CREATE TABLE "
			+ EntryDAO.Entries.TABLE_NAME + " (" + EntryDAO.Entries._ID
			+ " INTEGER PRIMARY KEY," + EntryDAO.Entries.COLUMN_NAME_STARTTIME
			+ " REAL," + EntryDAO.Entries.COLUMN_NAME_ENDTIME + " REAL,"
			+ EntryDAO.Entries.COLUMN_NAME_BREAK + " INTEGER" + ");";

	private static final String DICTIONARY_TABLE_UPDATE = "UPDATE TABLE "
			+ EntryDAO.Entries.TABLE_NAME + " (" + EntryDAO.Entries._ID
			+ " INTEGER PRIMARY KEY," + EntryDAO.Entries.COLUMN_NAME_STARTTIME
			+ " REAL," + EntryDAO.Entries.COLUMN_NAME_ENDTIME + " REAL,"
			+ EntryDAO.Entries.COLUMN_NAME_BREAK + " INTEGER" + ");";

	WorkTimeDictionaryHelper(Context context) {
		super(context, DATABASE_NAME, null, DATABASE_VERSION);
	}

	@Override
	public void onCreate(SQLiteDatabase db) {
		db.execSQL(DICTIONARY_TABLE_CREATE);
	}

	@Override
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
		db.execSQL(DICTIONARY_TABLE_UPDATE);
	}
}